import dayjs from "dayjs"
import { useState } from "react"


export const useDate = () => {
  const [date, setDate] = useState(new Date())
  const [visible, setVisible] = useState(false)

  const onShowDate = () => setVisible(true)

  const onHideDate = () => setVisible(false)

  const dayjsDate = dayjs(date)

  const onDateChange = (date) => {
    setDate(date)
  }

  return {
    visible,
    date: dayjsDate,
    onShowDate,
    onHideDate,
    onDateChange
  }
}